<?php

namespace app\controller;

use app\BaseController;

class Black extends BaseController
{
    /**
     * 查看QQ黑名单
     */
    public function getList(){
        $list = $this->M('black')->where(['stat'=>1])->select();
        return pr(200,'success',$list);
    }
    /*
     * 添加QQ黑名单
     */
    public function addBlack()
    {
        $uid = $this->getUid();
        if(empty($uid)) return pr(300,'请先登录');
        $qq = request()->post('qq');
        //理由
        $reason = request()->post('reason');
        //服务器名
        $server = request()->post('server');
        //玩家id
        $bid = request()->post('bid');
        //证据贴链接
        $url = request()->post('url');


//        if (empty($bid)) return pr(300, '参数错误');
        try{
            $this->M('black')->insert([
                'qq'=>$qq,
                'reason'=>$reason,
                'server'=>$server,
                'bid'=>$bid,
                'uid'=>$uid,
                'url'=>$url,
                'stat'=>1,
                'time'=>time()
            ]);
        } catch (\Exception $e){
            return pr(300,$e->getMessage());
        }
       return pr(200, 'success');
    }

}